package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	MysqlConfig struct {
		User     string
		Password string
		Host     string
		Port     int
		Data     string
	}

	RedisConfig struct {
		Host     string
		Password string
		Db       int
	}
}

var AppConf Config

func Init() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置解析失败")
		return
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		fmt.Println("配置失败")
		return
	}
	fmt.Println("配置成功")

}
